package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * 上传图片
     *
     * @param multipartFile
     * @return
     */
    @PostMapping("upload_picture")
    public ResponseResult uploadFile(@RequestBody MultipartFile multipartFile) {

        return wmMaterialService.uploadFile(multipartFile);

    }

    /**
     * 素材展示
     *
     * @param wmMaterialDto
     * @return
     */
    @PostMapping("list")
    public ResponseResult list(@RequestBody WmMaterialDto wmMaterialDto) {

        return wmMaterialService.list(wmMaterialDto);

    }

    /**
     * 素材收藏
     * 根据素材id收藏
     * @param id
     * @return
     */
    @GetMapping("collect/{id}")
    public ResponseResult collect(@PathVariable Long id) {

        return wmMaterialService.collect(id);

    }
}
